// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import FastClick from 'fastclick'
import '@/assets/style/style.scss'
import '@/assets/fonts/font_u/iconfont.css'
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store'

// 全局组件
import button from '@/components/button'
import header from '@/components/header'
import MintUI from 'mint-ui'
import '@/utils/directives'
import VeeValidate,{Validator} from 'vee-validate';
import '@/permission' // permission control
import Toast from '@/components/toast.vue'
import zh_CN from 'vee-validate/dist/locale/zh_CN';
import VueI18n from 'vue-i18n';
Vue.use(VueI18n)
const i18n = new VueI18n({
    locale: 'zh_CN',
})
Vue.use(VeeValidate, {
    i18n,
    i18nRootKey: 'validation',
    dictionary: {
        zh_CN
    }
});
Vue.component('ui-button', button)
Vue.component('ui-header', header)
Vue.component('Toast', Toast)

Vue.use(MintUI)
Vue.use(VeeValidate);

Validator.extend('phone', {

    getMessage: field =>   '必须是11位手机号码',
    validate: value => {
        return value.length == 11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/.test(value)
    }
});
Validator.extend('identity', {

    getMessage: field =>   '身份证号码错误',
    validate: value => {
        return (/\d{17}[\d|x]|\d{15}/).test(value) && (value.length == 15 || value.length == 18)
    }
});
const dictionary = {
    zh_CN: {
        messages: {
            // <input type="text" v-model="phoneNumber" name="phone" v-validate="'required|phone'">
            // 不满足required条件时，显示的提示对应下面的设置
            required: (field) => ` 不能为空`,
            decimal: (field) => `必须是数字`,
        },
        attributes: {
            // <input type="text" v-model="phoneNumber" name="phone" v-validate="'required|phone'">
            // 上述messages提示信息中field显示的内容在此设置，对应标签的name属性
            phone: 'Phone Number',
        }
    }
}
Validator.localize('zh_CN', zh_CN)
Validator.localize(dictionary);



Vue.config.productionTip = false
FastClick.attach(document.body)

/* eslint-disable no-new */
new Vue({
    el: '#app',
    router,
    store,
    components: { App },
    template: '<App/>'
})
